package com.tongji.showroom.model
{	

	import com.adobe.serialization.json.JSON;
	
	import flash.display.BitmapData;
	
	import mx.collections.ArrayCollection;
	
	import org.robotlegs.mvcs.Actor;
	
	/**
	 * 
	 * @author chenzhongyuan
	 * 2011/7/19
	 **/
	
	[Bindable]
	public class ProductModel extends Actor
	{
		//主要针对第一层中的组件
		public var pictureArray:ArrayCollection = new ArrayCollection(); //存储显示在左侧list中的图片
		public var tempArray:ArrayCollection = new ArrayCollection(); //存储显示在右侧list中的图片
		public var pictureNum:int = 0; //表示待上传的图片总数
		public var defaultSource:String = "images/Default.png";//存储右侧大图片的位置
		public var str:String;
		public var pictureId:Number;
		public var prePic:BitmapData;
		public var currentArray:ArrayCollection = new ArrayCollection();
		public function ProductModel()
		{
			super();
		}
		
		//从服务器下载所上传的图片
		public function updatePicture(str:String):void
		{
			this.str = str;
			var arr:Array = (JSON.decode(str) as Array);
			tempArray = new ArrayCollection(arr);
		}
		
		//删除model中存储的对应图片
		public function deletePic(pictureId:Number):void
		{
			for (var i:int = 0; i < tempArray.length; i ++)
			{
				if (tempArray[i].pid == pictureId)
					tempArray.removeItemAt(i);
			}
		}		
	}
}